<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>问题详情</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<link href="${BasePath}/course/css/bootstrap.min.css" rel="stylesheet" />
			<link href="${BasePath}/course/font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">
		<link href="${BasePath}/course/css/styles.css" rel="stylesheet" />
		<link href="${BasePath}/course/css/layer.css" rel="stylesheet" />
		<script type="text/javascript" src="${BasePath}/course/js/zepto.js"></script>
		<script type="text/javascript" src="${BasePath}/course/js/main.js"></script>
		<style>
			.layui-layer-dialog .layui-layer-content {
				text-align: center;
			}
			.layui-layer-btn .layui-layer-btn0 {
				border-color: rgba(112,169,91,1) !important;
				background-color: rgba(112,169,91,1) !important;
			}
		</style>
	</head>
	<body style="background: #f5f5f5;">
		<div id="container-div" class="wraaper width100" style="background: #ffffff;">
			<div class="container width90">
				<div class="header">
					<i class="fa fa-angle-left his-back back" id="back" ></i>
				</div>
				<!--内容区-->
				<div class="qu-main"><!--qu-main begin-->
				  <div class="">
					<div class="fmi-n fs-p16">${question.descr}</div>
					<p class="fmi-t fs-p13 mt1">${question.createTime?string("yyyy-MM-dd HH:mm:ss")}</p>
				  </div>
				</div><!--qu-main end-->
			</div>
			<div class="bg-tip"></div>

			<#if (answer.yangCoin == 0 || isPay == 0)>
				<!--已回答列表-->
				 <div class="container width90">
					<div class=""><!--qu-main begin-->
					  <div class="">
						<div class="fmi-n fs-p16">他的回答</div>
						<p class="fmi-t fs-p13 mt1">${answer.content}</p>
					  </div>
					</div><!--qu-main end-->
				 </div>
			 </#if>
	  	</div>
		<#if (answer.yangCoin > 0 && isPay == 1)>
			<div class="width100 text-center qu-btn"><span  class="btn-large green button" id="showAnswerBtn">${answer.yangCoin}氧币查看答案</span></div>
		</#if>
		<script type="text/javascript" src="${BasePath}/course/js/layer.js"></script>
		<script type="text/javascript" src="${BasePath}/js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="${BasePath}/js/weixinAjaxHeader.js"></script>
		<script>
			$("#showAnswerBtn").click(function(){
                if("${isLogin}" == 0) {
                    layer.open({
						content: '正在购买'
						,skin: 'msg'
						,time: 1 //1秒后自动关闭
					});
                    var payResult = pay();
                    if (payResult) {
                        var content = "<div class=\"container width90\">" +
                            "<div><!--qu-main begin-->" +
                            "<div>" +
                            "<div class=\"fmi-n fs-p16\">他的回答</div>" +
                            "<p class=\"fmi-t fs-p13 mt1\">${answer.content}</p>" +
                            "</div>" +
                            "</div><!--qu-main end-->" +
                            "</div>";
						$("#container-div").append(content);
                        $(".qu-btn").css('display','none');
                    }
                }
                else
				{
                    window.location.href = "${BasePath}/page/weixin/login";
				}
			});
            function pay(){
                var ret = false;
                var requestData = {
                    "questionId":"${question.id}",
                    "memberId":"${memberId}",
                    "coinCount":"${answer.yangCoin}"
                };
                console.log("request data:" + JSON.stringify(requestData));
                $.ajax({
                    type: 'post',
                    cache:false,
                    async:false,
                    url: "${BasePath}/api/coin/payAnswer",
                    data: JSON.stringify({"requestData":JSON.stringify(requestData)}),
                    dataType: "json",
                    contentType : "application/json",
                    success: function(data){
                        console.log("response data:" + JSON.stringify(data));
                        if(data.code == 200){
                            ret = data.responseData;
                        }else{
                            layer.open({
                                content: data.error
                                ,skin: 'msg'
                                ,time: 1 //1秒后自动关闭
                            });
						}
                    },
                    error: function(request) {
                        prompt($(".prompt"), "系统繁忙，请稍候重试！");
                    }
                });
                return ret;
            }
		</script>
	</body>
</html>
